﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Drawing.Design;
using System.Windows.Forms;
using System.Windows.Forms.Design;

namespace Tools {
	public interface AssetPathHandler {
		/// <summary>
		/// Removes unnecessary parts of the path when running in the game such as the folder name in: 'Textures\32x32'
		/// Example output is: '32x32'
		/// </summary>
		/// <param name="path">Unsanitized or raw path from asset selector</param>
		/// <returns>Sanitized path</returns>
		string SanitizeAssetPath( string path );

		/// <summary>
		/// Adds the original unnecessary parts of the path when loading the asset sources in the tools program
		/// Example input and output,
		///  In: 32x32
		///  Out: Textures\32x32
		/// </summary>
		/// <param name="path">Sanitized path</param>
		/// <returns>Unsanitized or raw original path from asset selector</returns>
		string DesanitizeAssetPath( string path );
	}

	// ----------

	public class AssetPathHandlerAttribute : Attribute {
		public AssetPathHandlerAttribute( Type handler ) { HandlerType = handler; }
		public Type HandlerType	{ get; private set; }
	}

	// ----------

	public class TexturePathHandler : AssetPathHandler {
		public string SanitizeAssetPath( string path ) {
			// Handles the fixing of paths for textures
			return path.Replace( '/', '\\' ).Replace( "Textures\\", "" );
		}

		public string DesanitizeAssetPath( string path ) {
			// Handles the fixing of paths for textures
			return "Textures\\" + path.Replace( '/', '\\' );
		}
	}
}
